package realQuestion.kedaXunfei;

import java.util.HashMap;
import java.util.Scanner;

public class Main3 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int ans=n;



        StringBuffer sb1 = new StringBuffer();
        StringBuffer sb2 = new StringBuffer();
        for (int i = 0; i < n; i++) {
            sb1.append(scanner.next());
        }
        for (int i = 0; i < n; i++) {
            sb2.append(scanner.next());
        }
        String s1=sb1.toString();
        String s2 = sb2.toString();


        if (s1.equals(s2)){
            ans+=1;
        }else {
            ans+=2;
        }

        HashMap<String, String> map = new HashMap<>();

        for (int i = n-1; i >=2 ; i--) {
            for (int j = 0; j <=n-i; j++) {
                if(j+i<=n){
                    String substring = s1.substring(j, j + i);
                    if (!map.containsKey(substring)) {
                        map.put(substring,"");
                        ans++;
                    }
                }

            }
        }


        for (int i = n-1; i >=2 ; i--) {
            for (int j = 0; j <=n-i; j++) {
                if (j + i <= n) {
                    String substring = s2.substring(j, j + i);
                    if (!map.containsKey(substring)) {
                        map.put(substring, "");
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);



    }


}
